package com.kang.gym.Controller;

import com.kang.gym.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import javax.servlet.http.HttpSession;

/**
 * @author 86150
 */
@Controller
public class LoginController {


    @GetMapping("/toLogin")
    public  String loginPage(){
        return  "login";
    }
    @GetMapping("/login")
    public String login(@RequestParam String username, @RequestParam String password, HttpSession session, RedirectAttributes attributes) {

   return "login";
    }

    @GetMapping("/logout")
    public String logout(HttpSession session){
        session.removeAttribute("user");
        return "redirect:/toLogin";
    }

    @GetMapping("/register")
    public String toRegister(){
        return "register";
    }

}
